package com.fjwt.gz.service.activity.game.acte001;

import com.fjwt.gz.core.utils.ExportExcelUtil;
import com.fjwt.gz.db.vo.AwardScoreVO;
import com.fjwt.gz.db.vo.ExportAwardVO;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.util.List;

public class ACTE001ExportExcle {

    /**
     * 卡券奖品信息
     * @param
     * @param workbook
     * @param list
     */
    public static void createcouponsSheet(String remark, XSSFWorkbook workbook, List<ExportAwardVO> list){
        XSSFSheet sheet = workbook.createSheet(remark+"券奖品");
        String[] str = {"用户唯一ID","参与客户姓名","参与客户手机号","参与客户是否实名","领用卡券名称","卡券金额","微信唯一卡券编号","参与时间","核销时间", "卡券状态"};
        XSSFCellStyle cellStyle = ExportExcelUtil.cellStyle(workbook);
        CellStyle style = ExportExcelUtil.dateCellStyle(workbook);
        sheet.setColumnWidth(0,2000);
        sheet.setColumnWidth(1,5000);
        sheet.setColumnWidth(2,8000);
        sheet.setColumnWidth(3,8000);
        sheet.setColumnWidth(4,8000);
        sheet.setColumnWidth(5,8000);
        sheet.setColumnWidth(6,8000);
        sheet.setColumnWidth(7,8000);
        sheet.setColumnWidth(8,8000);
        sheet.setColumnWidth(9,8000);
        //行号
        int rowNum = 0;
        XSSFRow row = sheet.createRow(rowNum++);
        for(int i=0;i<str.length;i++){
            row.createCell(i).setCellValue(str[i]);
            row.getCell(i).setCellStyle(cellStyle);
        }
        for(ExportAwardVO s:list){
            XSSFRow row2 = sheet.createRow(rowNum++);
            row2.createCell(0).setCellValue(s.getFansId());
            row2.createCell(1).setCellValue(s.getRealName());
            row2.createCell(2).setCellValue(s.getPhone());
            row2.createCell(3).setCellValue(s.getIsAuth());
            row2.createCell(4).setCellValue(s.getCouponName());
            row2.createCell(5).setCellValue(s.getCouponPrice());
            row2.createCell(6).setCellValue(s.getCouponThirdId());
            row2.createCell(7).setCellValue(s.getCreatedAt());
            row2.createCell(8).setCellValue(s.getWriteTime());
            row2.createCell(9).setCellValue(s.getStatus());

            row2.getCell(0).setCellStyle(cellStyle);
            row2.getCell(1).setCellStyle(cellStyle);
            row2.getCell(2).setCellStyle(cellStyle);
            row2.getCell(3).setCellStyle(cellStyle);
            row2.getCell(4).setCellStyle(cellStyle);
            row2.getCell(5).setCellStyle(cellStyle);
            row2.getCell(6).setCellStyle(cellStyle);
            row2.getCell(7).setCellStyle(style);
            row2.getCell(8).setCellStyle(style);
            row2.getCell(9).setCellStyle(cellStyle);
        }
    }

    /**
     * 实物奖品信息
     * @param remark
     * @param workbook
     * @param list
     */
    public static void createGoodsSheet(String remark,XSSFWorkbook workbook,List<ExportAwardVO> list){
        XSSFSheet sheet = workbook.createSheet(remark+"实物奖品");
        String[] str = {"用户唯一ID","参与客户姓名","参与客户手机号","参与客户是否实名","领用卡券名称","卡券金额","微信唯一卡券编号","参与时间","核销时间", "卡券状态"};
        XSSFCellStyle cellStyle = ExportExcelUtil.cellStyle(workbook);
        CellStyle style = ExportExcelUtil.dateCellStyle(workbook);
        sheet.setColumnWidth(0,2000);
        sheet.setColumnWidth(1,5000);
        sheet.setColumnWidth(2,8000);
        sheet.setColumnWidth(3,8000);
        sheet.setColumnWidth(4,8000);
        sheet.setColumnWidth(5,8000);
        sheet.setColumnWidth(6,8000);
        sheet.setColumnWidth(7,8000);
        sheet.setColumnWidth(8,8000);
        sheet.setColumnWidth(9,8000);
        //行号
        int rowNum = 0;
        XSSFRow row = sheet.createRow(rowNum++);
        for(int i=0;i<str.length;i++){
            row.createCell(i).setCellValue(str[i]);
            row.getCell(i).setCellStyle(cellStyle);
        }
        for(ExportAwardVO s:list){
            XSSFRow row2 = sheet.createRow(rowNum++);
            row2.createCell(0).setCellValue(s.getFansId());
            row2.createCell(1).setCellValue(s.getRealName());
            row2.createCell(2).setCellValue(s.getPhone());
            row2.createCell(3).setCellValue(s.getIsAuth());
            row2.createCell(4).setCellValue(s.getCouponName());
            row2.createCell(5).setCellValue(s.getCouponPrice());
            row2.createCell(6).setCellValue(s.getCouponThirdId());
            row2.createCell(7).setCellValue(s.getCreatedAt());
            row2.createCell(8).setCellValue(s.getWriteTime());
            row2.createCell(9).setCellValue(s.getStatus());

            row2.getCell(0).setCellStyle(cellStyle);
            row2.getCell(1).setCellStyle(cellStyle);
            row2.getCell(2).setCellStyle(cellStyle);
            row2.getCell(3).setCellStyle(cellStyle);
            row2.getCell(4).setCellStyle(cellStyle);
            row2.getCell(5).setCellStyle(cellStyle);
            row2.getCell(6).setCellStyle(cellStyle);
            row2.getCell(7).setCellStyle(style);
            row2.getCell(8).setCellStyle(style);
            row2.getCell(9).setCellStyle(cellStyle);
        }
    }

    /**
     * 福分奖品信息
     * @param
     * @param workbook
     * @param list
     */
    public static void createScoreSheet(XSSFWorkbook workbook,List<AwardScoreVO> list){
        //2.创建一个sheet
        XSSFSheet sheet = workbook.createSheet("B2券奖品");
        String[] str={"客户id","客户姓名","客户手机号","是否实名","福分名称","福分值","参与时间","入链渠道","入链账号","入链账号名称","入链账号所属网点机构号"};
        XSSFCellStyle cellStyle = ExportExcelUtil.cellStyle(workbook);
        CellStyle style = ExportExcelUtil.dateCellStyle(workbook);
        sheet.setColumnWidth(0,2000);
        sheet.setColumnWidth(1,5000);
        sheet.setColumnWidth(2,8000);
        sheet.setColumnWidth(3,8000);
        sheet.setColumnWidth(4,8000);
        sheet.setColumnWidth(5,8000);
        sheet.setColumnWidth(6,8000);
        sheet.setColumnWidth(7,8000);
        sheet.setColumnWidth(8,8000);
        sheet.setColumnWidth(9,8000);
        sheet.setColumnWidth(10,8000);
        //行号
        int rowNum = 0;
        XSSFRow row = sheet.createRow(rowNum++);
        for(int i=0;i<str.length;i++){
            row.createCell(i).setCellValue(str[i]);
            row.getCell(i).setCellStyle(cellStyle);
        }
        for(AwardScoreVO s:list){
            XSSFRow row2 = sheet.createRow(rowNum++);
            row2.createCell(0).setCellValue(s.getFansId());
            row2.createCell(1).setCellValue(s.getRealName());
            row2.createCell(2).setCellValue(s.getPhone());
            row2.createCell(3).setCellValue(s.getIsAuth());
            row2.createCell(4).setCellValue(s.getName());
            row2.createCell(5).setCellValue(s.getScore());
            row2.createCell(6).setCellValue(s.getCreateTime());
            row2.createCell(7).setCellValue(s.getMchChannel());
            row2.createCell(8).setCellValue(s.getChannelCode());
            row2.createCell(9).setCellValue(s.getChannelName());
            row2.createCell(10).setCellValue(s.getAgentNo());

            row2.getCell(0).setCellStyle(cellStyle);
            row2.getCell(1).setCellStyle(cellStyle);
            row2.getCell(2).setCellStyle(cellStyle);
            row2.getCell(3).setCellStyle(cellStyle);
            row2.getCell(4).setCellStyle(cellStyle);
            row2.getCell(5).setCellStyle(cellStyle);
            row2.getCell(6).setCellStyle(style);
            row2.getCell(7).setCellStyle(cellStyle);
            row2.getCell(8).setCellStyle(cellStyle);
            row2.getCell(9).setCellStyle(cellStyle);
            row2.getCell(10).setCellStyle(cellStyle);
        }
    }
}
